#程序文件 - mme2024-example-7-11-b.py

import numpy as np
#import matplotlib.pyplot as plt

x=np.array([5.764, 6.286, 6.759, 7.168, 7.408])
y=np.array([0.648, 1.202, 1.823, 2.526, 3.36 ])

A=np.vstack([x**2,x*y,y**2,x,y]).T
b=-np.ones(5)
c=np.linalg.inv(A)@b
print('The coefficients are:', np.round(c,4))

# 使用符号计算sympy的隐函数画图
import sympy as sy
import sympy.plotting as syp

xa = sy.symbols('xa')
ya = sy.symbols('ya')
G = c[0]*xa**2+c[1]*xa*ya+c[2]*ya**2+c[3]*xa+c[4]*ya+1   
syp.plot_implicit(G,(xa,3,8),(ya,-2,5),line_color='b')

